#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

// 1751. 最多可以参加的会议数目 II
// https://leetcode.cn/problems/maximum-number-of-events-that-can-be-attended-ii/description/?envType=daily-question&envId=2025-07-08

class Solution
{
public:
    int recursionTry(vector<vector<int>> &events, int k, int curStart, int index, vector<vector<int>> &dp)
    {
        if (k == 0 || events.size() == index)
        {
            return 0;
        }

        if (dp[index][k] != -1)
        {
            return dp[index][k];
        }

        int ret = 0;
        if (events[index][0] <= curStart)
        {
            ret = recursionTry(events, k, curStart, index + 1, dp);
        }
        else
        {
            ret = max(recursionTry(events, k - 1, events[index][1], index + 1, dp) + events[index][2],
                      recursionTry(events, k, curStart, index + 1, dp));
        }
        dp[index][k] = ret;
        return ret;
    }
    int maxValue(vector<vector<int>> &events, int k)
    {
        vector<vector<int>> dp(events.size(), vector<int>(k + 1, -1));
        sort(events.begin(), events.end(), [](vector<int> &a, vector<int> &b)
             { return a[0] < b[0]; });
        return recursionTry(events, k, 0, 0, dp);
    }
};

class Solution1
{
public:
    int maxValue(vector<vector<int>> &events, int k)
    {
    }
};

int main()
{
    vector<vector<int>> event{
        {1, 3, 4},
        {1, 1, 4},
        {2, 5, 5}};
    Solution solution{};
    int res = solution.maxValue(event, 3);
    return 0;
}